import Vue from 'vue'
import App from './App'
import store from './store'
import modules from './router/modules/home.js'
import Router, {RouterMount} from 'uni-simple-router'
// import http from './api/http.js'
import uView from "uview-ui";

// import VConsole from 'vconsole';
// let vConsole = new VConsole();

Vue.use(uView);
Vue.use(Router)

var VueTouch = require('vue-touch')
Vue.use(VueTouch, {name: 'v-touch'})

let list = ['iPhone X', 'iPhone XR', 'iPhone 11', 'iPhone 11Pro', 'iPhone 11Pro Max', 'iPone 12 mini', 'iPhone 12', 'iPhone 12 Pro', 'iPhone 12 Pro Max']
let phone = uni.getSystemInfoSync().model
let phoneState = list.some(item =>{
	console.log(phone.indexOf(item))
	return phone.indexOf(item) != -1
})
if(phoneState){
	store.dispatch('setiPhone')
}

// uni.removeStorageSync('cid')

uni.showLoading({
	title: '加载中...'
})
const router = new Router({
    routes: [...modules]//路由表
});

//全局路由前置守卫

router.beforeEach((to, from, next) => {
	// var ua = navigator.userAgent.toLowerCase();
	// if (ua.match(/MicroMessenger/i) == "micromessenger") {
	// 	console.log("【查看当前环境】：是微信环境")
	// 	if(window.location.search){
	// 		var url = window.location.pathname + window.location.search
	// 	}else{
	// 		var url =window.location.pathname
	// 	}
	// 	console.log(window.location)
	// 	uni.request({
	// 		url: 'http://taikon-book-api.canskj.cn/api/weixin/info', 
	// 		data:{path:url},
	// 		success: (res) => {
	// 			window.location.href = res.data.data.url
	// 		}
	// 	});
	// } else {
	// 	// alert('不是微信')
	// 	router.push({path: '/pages/index/auth'})
	// }
	next()  //放行
})

Vue.prototype.$store = store

Vue.config.productionTip = false
// 挂载全局
// Vue.prototype.$http = http

App.mpType = 'app'

const app = new Vue({
    ...App
})
// #ifdef H5
	RouterMount(app,'#app');
// #endif

// #ifndef H5
	app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif
